"""
# yield语法:   那他看成一个迭代器

先执行yield之前的代码
在输出 yield的返回值(谁调用就给谁)
yield之后的代码

"""
# def my_gen():
#     print("Start")
#     yield 1
#     print("Middle")
#     yield 2
#     print("End")
#
# for i in my_gen():
#     print(f"Got: {i}")


def gen_func(max):
    n=1
    while n<max:

        yield n
        n+=1
num=gen_func(5)
print(next(num))
print(next(num))
print(next(num))
print(next(num))
# print(gen_func(5))
# print(gen_func(5))
# print(gen_func(5))
# print(gen_func(5))





#
# num=gen_func(5)
# print(next(num))
# print(next(num))
# print(next(num))